<div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
        <div class="x_title">
            <h2>{$pri_name} <small></small></h2>
            <ul class="nav navbar-right panel_toolbox">
                {:check_create('create',['type_id'=>input('type_id')])}
            </ul>
            <div class="clearfix"></div>
        </div>
        <div class="x_content">
            <p class="text-muted font-13 m-b-30">
                <code>说明:</code>{$code}
            </p>
            <form id="search" action="{:url('index')}" />

            <input type="hidden" name="page" value="1"/>

            <div class="well" style="overflow: auto">
                <div class="col-md-2">
                    <input type="text" name="title" autocomplete="off" class="form-control" placeholder="请输入搜索内容..." value="{:input('title')}">
                </div>
                <div class="col-md-2">
                    <select name="company_id" onchange="sub(this.value)" class="select2 js-states form-control"
                            style="width: 100%;">
                        <option value="0">全部公司名称</option>
                        {volist name="$leasing_company" id="item"}
                        <option value="{$item.id}" {eq name=":input('company_id')" value="$item.id" }selected{/eq}>{$item.title}</option>
                        {/volist}
                    </select>
                </div>
                <div class="col-md-1">
                    <select name="project_id" class="select2 js-states form-control" style="width: 100%;">
                        <option value="0">全部项目名称</option>
                        {volist name="$project" id="item"}
                        <option value="{$item.id}" {eq name=":input('project_id')" value="$item.id" }selected{/eq}>{$item.title}</option>
                        {/volist}
                    </select>
                </div>

<!--                <div class="col-md-1">-->
<!--                    <select name="online_status" class="select2 js-states form-control"  style="width: 100%;">-->
<!--                        <option value="0">全部在线状态</option>-->
<!--                        <option value="1" {eq name=":input('online_status')" value="1"}selected{/eq}>开机</option><option value="2" {eq name=":input('online_status')" value="2"}selected{/eq}>关机</option>-->
<!--                    </select></div>-->
                <div class="col-md-2">
                    <input type="text" name="create_time" autocomplete="off" class="form-control" id="interval_timer" style="width: 100%" placeholder="请选择时间区间..." value="{:input('create_time')}">
                </div>

                <div class="col-md-1">
                    <button type="submit" class="btn btn-success">搜 索</button>
                </div>
            </div>
            </form>
            <div style="overflow: auto">
                <table id="datatables" class="table table-striped table-bordered">
                    <thead>
                    <tr>
                        <!--<th><input type="checkbox" onclick="CheckAll(this.checked)"></th></th>-->
                        <th width="20">
                        <input type="checkbox" onclick="CheckAll(this.checked)"></th>
                    </th>
                        <th width="40" style="text-align: center;">ID</th>

                        <th >设备号</th>
                        <th >吊篮状态</th>
                        <th >远程状态</th>
                        <th >故障类型</th>
                        <th >平衡状态</th>
                        <th >过载状态</th>
                        <th >在线状态</th>
                        <th >设备码</th>
                        <th >序号</th>
                        <th >铭牌号</th>
                        <th >公司名称</th>
                        <th >项目名称</th>
                        <th>起租状态</th>
                        <th>起租开始时间</th>
                        <th>起租结束时间</th>
                        <th >年费开始时间</th>
                        <th >年费结束时间</th>
                        <th >年费延迟时间</th>

                        <th width="140">创建时间</th>
                        <th width="130">操作</th>
                    </tr>
                    </thead>
                    <form id="form_volist">
                     <tbody>
                        {volist name="data" id="vo"}
                        <tr>
                            <th width="20">
                        <input type="checkbox" name="id[]" value="{$vo.id}"/>
                    </th>
                            <td width="40" style="text-align: center;">{$vo.id}</td>

                            <td>{$vo.title}</td>
                            <td>{$vo.use_status}</td>
                            <td>{$vo.remote_status}</td>
                            <td>{$vo.error}</td>
                            <td>{$vo.balance}</td>
                            <td>{$vo.overload}</td>
                            <td>{$vo.online_status}</td>
                            <td><img class="xj_img" height="35" src="{$vo.qrcode}" /></td>
                            <td>{$vo.id_no}</td>
                            <td>{$vo.name_no}</td>
                            <td>{$vo.company_title}</td>
                            <td>{$vo.project_title}</td>
                            <td>{$vo.is_rent_title}</td>
                            <td>{$vo.rent_start_time}</td>
                            <td>{$vo.rent_end_time}</td>
                            <td>{$vo.start_time}</td>
                            <td>{$vo.end_time}</td>
                            <td>{$vo.delay_time}</td>


                            <td>{$vo.create_time}</td>
                            <td>
                                {:diy_button('active',['id'=>$vo.id],['style'=>'btn-primary','size'=>'btn-xs','a'=>false,'attr'=>['id'=>$vo.id,'company_id'=>$vo.company_id,'title'=>$vo.title,'project_id'=>$vo.project_id]])}
                                <button style="background-color: #009688;border:1px solid #009688" class="more btn btn-info btn-xs" data-title="{$vo.title}" data-id="{$vo.id}">发送指令</button>
                                {:check_update('update',['id' => $vo.id])}
                                {:check_destory('destory',['id' => $vo.id])}
                            </td>
                        </tr>
                        {/volist}
                    </tbody>
                    </form>

                        <script>
                            $('#upload').click(function () {
                                $("#read").submit();
                            });
                        </script>
                    <tfoot align="left">
                    <tr>
                        <td colspan="100">
                            <span>控制：</span>
                            
                        </td>
                    </tr>
                    </tfoot>

                </table>
            </div>

            <div style="text-align: right;">{$data|raw}</div>
        </div>
    </div>
</div>
<!--&lt;!&ndash; 給layer 下拉等引入 &ndash;&gt;-->
<!--<link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">-->
<!--&lt;!&ndash; 引入 layui.js &ndash;&gt;-->
<!--<script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>-->
<script src="__PLUGIN__/layui-master/dist/layui.js"></script>
<script>
    function sub(v) {
        window.location.href = "{:url('index')}?page=1&company_id="+v+"&title={:input('title')}"+"&project_id=0";
    }
</script>
<script>

    $('.click_active').click(function () {
        var id = $(this).attr('attr-id');
        var company_id = $(this).attr('attr-company_id');
        var title = $(this).attr('attr-title');
        var year_fee = "{:cache('year_free')}";
        var project_id  =  $(this).attr('attr-project_id');
        layer.confirm('这会扣除'+year_fee+'的账户余额,然后签约1年使用权限', {
            btn: ['签约','取消'] //按钮
        }, function(){
            $.ajax({
                type: "POST", //用POST方式传输
                dataType: "json", //数据格式:JSON
                data: {id: id,company_id:company_id,title:title,project_id:project_id},
                url: "{:url('active')}", //目标地址
                async: false,
                success: function (ret) {
                    if (ret.code == 200) {
                        layer.msg(ret.msg);
                        // layer.close(index);
                        setInterval(function () {
                            history.go(0);
                        },3000);
                        // layer.msg(data.message);
                        return false;
                    } else {
                        layer.msg(ret.msg);
                        return false;
                    }
                }
            });
        }, function(){
            // layer.msg('也可以这样', {
            //     time: 20000, //20s后自动关闭
            //     btn: ['明白了', '知道了']
            // });
        });


    });

    layui.use('dropdown', function(){
        var dropdown = layui.dropdown
            ,$ = layui.jquery;

        dropdown.render({
            elem: '.more'
            , data: [
                {
                    title: '开机'
                    , type: 'Openn',

                }, {
                    title: '关机'
                    , type: 'Close'
                }, {
                    title: '暂停'
                    , type: 'Pause'
                }, {
                    title: '平衡(开)'
                    , type: 'BalON'
                }
                , {
                    title: '平衡(关)'
                    , type: 'BaOFF'
                }
                , {
                    title: '超载(开)'
                    , type: 'OvON'
                }
                , {
                    title: '超载(关)'
                    , type: 'OvOFF'
                }
            ]

            ,click: function(data, othis){ //data下单菜单
                var elem = $(this.elem),title = elem.data('title'),cmd = elem.data('type'),id = elem.data('id'); //表格列表的预埋数据

                console.log(id);
                    $.ajax({
                        type: "POST", //用POST方式传输
                        dataType: "json", //数据格式:JSON
                        data:{device_name:title,cmd:data.type,id:id},
                        url: "{:url('api/Aliyuniot/pub')}", //目标地址
                        async: false,
                        success: function (ret) {
                            if(ret.code == 200){
                                layer.msg(ret.msg);
                                layer.close(index);
                                // layer.msg(data.message);
                                return false;
                            }else{
                                layer.msg(ret.msg);
                                return false;
                            }
                        }
                    });

                //layer.msg('得到表格列表的 member_id：'+ member_id +'，下拉菜单 id：'+ data.id);
                $('.layui-layer-content').find('input').attr('min',1);
                if(data.type == 'integral_recharge'){
                    layer.prompt({title:'充值积分'},function(val, index){ //当前值val
                        $.ajax({
                            type: "POST", //用POST方式传输
                            dataType: "json", //数据格式:JSON
                            data:{token:member_id,integral:val},
                            url: "{:url('integral_recharge')}", //目标地址
                            async: false,
                            success: function (ret) {
                                if(ret.code == 200){
                                    layer.msg(ret.msg);
                                    layer.close(index);
                                    // layer.msg(data.message);
                                    return false;
                                }else{
                                    layer.msg(ret.msg);
                                    return false;
                                }
                            }
                        });

                    });
                }
                //以后积分充值
                if(data.type == 'level'){
                    layer.open({

                        btn: ['确认','取消'],

                        title:['操作'],

                    }, function () {

                        var lev =$('#lev').val();

                        $.ajax({

                            type: 'post',

                            url: "/admin/mem/levr6PhjI",

                            data:{'lev':lev,'memid':data.memid},

                            success: function (response) {

                                if(response.code==0){

                                    layer.close(layer.index);

                                    reloads();

                                    layer.alert('修改成功', {icon: 6, time: 3000});

                                }else{

                                    layer.close(layer.index);

                                    layer.alert('修改失败', {icon: 2, time: 3000});

                                }



                                form.render('select');

                            }

                        })

                    }, function () {



                    });
                    $(".layui-layer-content").append("	<br/><div class='layui-inline'>  <div class=\"layui-inline\">\n" +

                        "                    <label class=\"layui-form-label\">级别</label>\n" +

                        "                    <div class=\"layui-input-inline\"  style=\"width: auto;\">\n" +

                        "                        <select name='lev' id='lev' style='height: 30px'   lay-filter=\"lev\">\n" +

                        "                            <option value=\"0\">0</option>\n" +

                        "                            <option value=\"1\">1</option>\n" +

                        "                            <option value=\"2\">2</option>\n" +

                        "                            <option value=\"3\">3</option>\n" +

                        "                            <option value=\"4\">4</option>\n" +

                        "                            <option value=\"5\">5</option>\n" +

                        "                            <option value=\"6\">6</option>\n" +

                        "                            <option value=\"7\">7</option>\n" +

                        "                            <option value=\"8\">8</option>\n" +

                        "                            <option value=\"9\">9</option>\n" +

                        "                            <option value=\"10\">10</option>\n" +

                        "\n" +

                        "                        </select>\n" +

                        "                    </div>\n" +

                        "                </div></div> </div>");
                }

            }
        });
    });
</script>
